package com.wd.servlet;

import com.wd.entity.Log;
import com.wd.service.LogService;
import com.wd.service.impl.LogServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author: 悠久的苍穹
 * @Date: 2020/11/9 16:22
 * @Description: ${description}
 * @Version: 1.0
 */
@WebServlet(urlPatterns = "/LogServlet")
public class LogServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        request.setCharacterEncoding("UTF-8");
        LogService logService = new LogServiceImpl();
        try {
            List<Log> logList = logService.selLog();
            request.setAttribute("logList",logList);
            request.getRequestDispatcher("log.jsp").forward(request,response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
